home *** CD-ROM | disk | FTP | other *** search
- Path: rs6.iaee.tuwien.ac.at!sor
- From: sor@rs6.iaee.tuwien.ac.at (Evgeni Sorokin)
- Newsgroups: comp.lang.c
- Subject: How do I round and truncate floats to integers?
- Date: 15 Feb 1996 19:07:23 GMT
- Organization: Vienna University of Technology, Austria
- Message-ID: <4g009b$c2n@news.tuwien.ac.at>
- NNTP-Posting-Host: rs6.iaee.tuwien.ac.at
- X-Newsreader: TIN [version 1.2 PL2]
-
- Hello!
-
- I am myself ashamed of posting such stupid questions, but FAQ's and
- books that I've found assume this to be too evident.
-
- Given a float (double, to be exact) how do I
-
- 1) round it to nearest integer (forget 0.5 problem for the moment) and
- 2) truncate it to the integer?
-
- I browsed include directories of my compilers (Turbo C and GNU) and
- have not found passing functions taking floats and returning
- integers. If typecasting is supposed to do the trick, then how do I
- distinguish cases 1) and 2)?
-
-
- Many thanks in advance.
-
- --
- Zhenya Sorokin
-
-
-